﻿/// <reference path="../../Scripts/jquery-1.6.1.js" />
function ShowModalDialog(url, args, data, callback) {
    var realData = {
        url: url,
        data: data,
        iframeWidth: args.iframeWidth,
        iframeHeight: args.iframeHeight,
        title: args.title
    };
    url = "template/ModalDialog.aspx?rnd=" + Math.random()
    var returnValue = window.showModalDialog(url, realData, args.argString());
    if (callback && $.isFunction(callback)) {
        return callback(returnValue);
    } else {
        return returnValue;
    }
}

function ModelArgs(width, height, resizeable, status, scroll, iframeWidth, iframeHeight, title) {
    return {
        width: width,
        height: height,
        resizeable: resizeable,
        status: status,
        scroll: scroll,
        iframeWidth: iframeWidth,
        iframeHeight: iframeHeight,
        title: title,
        argString: function () {
            this.width = this.width || 500;
            this.height = this.height || 400;
            this.resizeable = this.resizeable || "yes";
            this.status = this.status || "yes";
            this.scroll = this.scroll || "yes";
            this.iframeWidth = this.iframeWidth || this.width;
            this.iframeHeight = this.iframeHeight || this.height;
            var args = "dialogWidth=" + this.width + "px;";
            args += "dialogHeight=" + this.height + "px;";
            args += "center=yes;";
            args += "resizable=" + this.resizeable + ";";
            args += "status=" + this.status + ";";
            args += "scroll=" + this.scroll + ";";
            return args;
        }
    };
}

function AddRecord() {
    var args = ModelArgs(844, 566, "no", "no", "yes", 840, 566, "添加记事");
    ShowModalDialog("../RecordProcess.aspx", args, null, DialogCallBack);
}
function DialogCallBack(str) {
    var id = refreshBtn || "";
    if (id != "" && !!str) {
        if (str.toLowerCase() == "ok") {
            $("#" + id).click();
        }
    }
}
function EditRecord(id) {
    var args = ModelArgs(844, 593, "no", "no", "yes", 840, 593, "修改记事");
    ShowModalDialog("../RecordProcess.aspx?id=" + id, args, null, DialogCallBack);
}

function AddRecordType() {
    var args = ModelArgs(454, 180, "no", "no", "yes", 450, 180, "添加记事分类");
    ShowModalDialog("../RecordTypeProcess.aspx", args, null, DialogTypeCallBack);
}

function DialogTypeCallBack(str) {
    if (str == "ok") {
        location.href = location.href;
    }
}
function EditRecordType(id) {
    var args = ModelArgs(454, 180, "no", "no", "yes", 450, 180, "修改记事分类");
    ShowModalDialog("../RecordTypeProcess.aspx?id=" + id, args, null, DialogTypeCallBack);
}